package com.ziyueyuwen.xiniao.service.baseservice.product.impl;

import com.ziyueyuwen.xiniao.bean.ZyProductInfo;
import com.ziyueyuwen.xiniao.bean.product.*;
import com.ziyueyuwen.xiniao.dao.ZyProductInfoMapper;
import com.ziyueyuwen.xiniao.enums.GradeEnum;
import com.ziyueyuwen.xiniao.enums.ProductClassRuleEnum;
import com.ziyueyuwen.xiniao.enums.ProductPeriodEnum;
import com.ziyueyuwen.xiniao.service.baseservice.product.ProductInfoBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wancheng  on 2019/2/20.
 */
@Service
public class ProductInfoBaseServiceImpl implements ProductInfoBaseService {

    @Autowired
    ZyProductInfoMapper zyProductInfoMapper;

    @Override
    public ZyProductInfo selectByPreKey(Integer id) {
        return zyProductInfoMapper.selectByPrimaryKey(id);
    }

    @Override
    public ZyProductInfo selectOneByZyCommodityInfo(ZyProductInfo param) {
        return zyProductInfoMapper.selectOne(param);
    }

    @Override
    public ZyProductInfo selectOneByClassId(Integer classId) {
        ZyProductInfo param = new ZyProductInfo();
        param.setClassId(classId);
        return zyProductInfoMapper.selectOne(param);
    }

    @Override
    public List<ZyProductInfo> selectListByZyCommodityInfo(ZyProductInfo param) {
        return zyProductInfoMapper.select(param);
    }

    @Override
    public List<ZyProductInfo> selectAll() {
        return zyProductInfoMapper.selectAll();
    }

    @Override
    public void save(ZyProductInfo product) {
        zyProductInfoMapper.insertUseGeneratedKeys(product);
    }

    @Override
    public void saveSelective(ZyProductInfo product) {
        zyProductInfoMapper.insertSelective(product);
    }

    @Override
    public void saveBatch(List<ZyProductInfo> product) {
        zyProductInfoMapper.insertList(product);
    }

    @Override
    public void update(ZyProductInfo product) {
        zyProductInfoMapper.updateByPrimaryKeySelective(product);
    }

    @Override
    public void deleteByPreKey(Integer id) {
        zyProductInfoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void delete(ZyProductInfo product) {
        zyProductInfoMapper.delete(product);
    }

    @Override
    public ProductVO selectProductAndStageByProductId(Integer productId) {
        return zyProductInfoMapper.selectProduct(productId);
    }


    @Override
    public List<ProductListVO> getProductListForPc(String productName, String className) {
        return zyProductInfoMapper.getProductListForPc(productName,className,null,null);
    }

    @Override
    public List<ProductListVO> getProductListForPc(String productName, String className,String courseName, Boolean ifUpperShelf) {
        return zyProductInfoMapper.getProductListForPc(productName,className,courseName,ifUpperShelf);
    }

    @Override
    public List<GradeEnum> getUpperProductGrade() {
        return zyProductInfoMapper.getUpperProductGrade();
    }

    @Override
    public List<ProductClassRuleEnum> getUpperProductClassRule(Integer courseId) {
        return zyProductInfoMapper.getUpperProductClassRule(courseId);
    }

    @Override
    public List<ZyProductInfo> getUpperProductPeriod(Integer courseId,Integer stageId,ProductClassRuleEnum classRule) {
        return zyProductInfoMapper.getUpperProductPeriod(courseId,stageId,classRule);
    }

    @Override
    public List<SaleCourseVO> getProductCourseInfo(GradeEnum gradeEnum) {
        return zyProductInfoMapper.getProductCourseInfo(gradeEnum);
    }

    @Override
    public List<SaleTeacherStatus> productTeacherStatus(Integer courseId) {
        return zyProductInfoMapper.productTeacherStatus(courseId);
    }

    @Override
    public List<SaleCourseDetailsVO> getSaleCourseDetails(SaleCourseDetailsQuery query) {
        return zyProductInfoMapper.getSaleCourseDetails(query);
    }

    @Override
    public Integer getStudentAvailable(Integer courseId) {
        return zyProductInfoMapper.getStudentAvailable(courseId);
    }
}
